<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/admin/login', 'Admin\LoginController@showLoginForm')->name('admin.showlogin');
Route::post('/admin/login', 'Admin\LoginController@login')->name('admin.login');

Route::group(['middleware' => ['get.menu']], function () {
    Route::get('/admin', function () {          
        return view('dashboard.homepage'); })->middleware('auth:admin')->name('admin.index');

    // Route::group(['middleware' => ['role:user']], function () {
    //     Route::get('/colors', function () {     return view('dashboard.colors'); });
    //     Route::get('/typography', function () { return view('dashboard.typography'); });
    //     Route::get('/charts', function () {     return view('dashboard.charts'); });
    //     Route::get('/widgets', function () {    return view('dashboard.widgets'); });
    //     Route::get('/404', function () {        return view('dashboard.404'); });
    //     Route::get('/500', function () {        return view('dashboard.500'); });
    //     Route::prefix('base')->group(function () {  
    //         Route::get('/breadcrumb', function(){   return view('dashboard.base.breadcrumb'); });
    //         Route::get('/cards', function(){        return view('dashboard.base.cards'); });
    //         Route::get('/carousel', function(){     return view('dashboard.base.carousel'); });
    //         Route::get('/collapse', function(){     return view('dashboard.base.collapse'); });

    //         Route::get('/forms', function(){        return view('dashboard.base.forms'); });
    //         Route::get('/jumbotron', function(){    return view('dashboard.base.jumbotron'); });
    //         Route::get('/list-group', function(){   return view('dashboard.base.list-group'); });
    //         Route::get('/navs', function(){         return view('dashboard.base.navs'); });

    //         Route::get('/pagination', function(){   return view('dashboard.base.pagination'); });
    //         Route::get('/popovers', function(){     return view('dashboard.base.popovers'); });
    //         Route::get('/progress', function(){     return view('dashboard.base.progress'); });
    //         Route::get('/scrollspy', function(){    return view('dashboard.base.scrollspy'); });

    //         Route::get('/switches', function(){     return view('dashboard.base.switches'); });
    //         Route::get('/tables', function () {     return view('dashboard.base.tables'); });
    //         Route::get('/tabs', function () {       return view('dashboard.base.tabs'); });
    //         Route::get('/tooltips', function () {   return view('dashboard.base.tooltips'); });
    //     });
    //     Route::prefix('buttons')->group(function () {  
    //         Route::get('/buttons', function(){          return view('dashboard.buttons.buttons'); });
    //         Route::get('/button-group', function(){     return view('dashboard.buttons.button-group'); });
    //         Route::get('/dropdowns', function(){        return view('dashboard.buttons.dropdowns'); });
    //         Route::get('/brand-buttons', function(){    return view('dashboard.buttons.brand-buttons'); });
    //     });
    //     Route::prefix('icon')->group(function () {  // word: "icons" - not working as part of adress
    //         Route::get('/coreui-icons', function(){         return view('dashboard.icons.coreui-icons'); });
    //         Route::get('/flags', function(){                return view('dashboard.icons.flags'); });
    //         Route::get('/brands', function(){               return view('dashboard.icons.brands'); });
    //     });
    //     Route::prefix('notifications')->group(function () {  
    //         Route::get('/alerts', function(){   return view('dashboard.notifications.alerts'); });
    //         Route::get('/badge', function(){    return view('dashboard.notifications.badge'); });
    //         Route::get('/modals', function(){   return view('dashboard.notifications.modals'); });
    //     });
    //     Route::resource('notes', 'NotesController');
    // });

    //Auth::routes();

    Route::group(['middleware' => ['auth:admin']], function () {
        // Route::resource('users',        'UsersController')->except( ['create', 'store'] );
        // Route::resource('roles',        'RolesController');
        // Route::get('/roles/move/move-up',      'RolesController@moveUp')->name('roles.up');
        // Route::get('/roles/move/move-down',    'RolesController@moveDown')->name('roles.down');
        // Route::prefix('menu/element')->group(function () { 
        //     Route::get('/',             'MenuElementController@index')->name('menu.index');
        //     Route::get('/move-up',      'MenuElementController@moveUp')->name('menu.up');
        //     Route::get('/move-down',    'MenuElementController@moveDown')->name('menu.down');
        //     Route::get('/create',       'MenuElementController@create')->name('menu.create');
        //     Route::post('/store',       'MenuElementController@store')->name('menu.store');
        //     Route::get('/get-parents',  'MenuElementController@getParents');
        //     Route::get('/edit',         'MenuElementController@edit')->name('menu.edit');
        //     Route::post('/update',      'MenuElementController@update')->name('menu.update');
        //     Route::get('/show',         'MenuElementController@show')->name('menu.show');
        //     Route::get('/delete',       'MenuElementController@delete')->name('menu.delete');
        // });
        // Route::prefix('menu/menu')->group(function () { 
        //     Route::get('/',         'MenuController@index')->name('menu.menu.index');
        //     Route::get('/create',   'MenuController@create')->name('menu.menu.create');
        //     Route::post('/store',   'MenuController@store')->name('menu.menu.store');
        //     Route::get('/edit',     'MenuController@edit')->name('menu.menu.edit');
        //     Route::post('/update',  'MenuController@update')->name('menu.menu.update');
        //     Route::get('/delete',   'MenuController@delete')->name('menu.menu.delete');
        // });
        // Route::prefix('media')->group(function () {
        //     Route::get('/',                 'MediaController@index')->name('media.folder.index');
        //     Route::get('/folder/store',     'MediaController@folderAdd')->name('media.folder.add');
        //     Route::post('/folder/update',   'MediaController@folderUpdate')->name('media.folder.update');
        //     Route::get('/folder',           'MediaController@folder')->name('media.folder');
        //     Route::post('/folder/move',     'MediaController@folderMove')->name('media.folder.move');
        //     Route::post('/folder/delete',   'MediaController@folderDelete')->name('media.folder.delete');;

        //     Route::post('/file/store',      'MediaController@fileAdd')->name('media.file.add');
        //     Route::get('/file',             'MediaController@file');
        //     Route::post('/file/delete',      'MediaController@fileDelete')->name('media.file.delete');
        //     Route::post('/file/update',     'MediaController@fileUpdate')->name('media.file.update');
        //     Route::post('/file/move',       'MediaController@fileMove')->name('media.file.move');
        //     Route::post('/file/cropp',      'MediaController@cropp');
        //     Route::get('/file/copy',        'MediaController@fileCopy')->name('media.file.copy');
        // });

        Route::prefix('admin')->namespace('Admin')->name('admin.')->group(function()
        {
            Route::resource('categories', 'CategoryController');
            Route::post('upload', 'UploadController@store')->name('upload.store');
            Route::resource('goods', 'GoodsController');
            Route::resource('brands', 'BrandController');
            Route::resource('swipers', 'SwiperController');
            Route::resource('anounces', 'AnounceController');
            Route::get('setting/config', 'ConfigController@create')->name('config.create');
            Route::post('setting/config', 'ConfigController@store')->name('config.store');

            Route::resource('setting/bottomnav', 'BottomnavController');
            
            Route::resource('users', 'UserController');
            Route::resource('orders', 'OrderController');
            Route::resource('payments', 'PaymentController');
            Route::resource('delivery', 'DeliveryController');
            Route::resource('bottomnav', 'BottomnavController');

            //改变商品上架状态
            Route::put('/status/{goods}/{type?}', 'GoodsStatusController@update')->name('goods.status.update');
        });
    });
});


//前台路由

Route::namespace('Home')->group(function(){
    Route::get('/', 'IndexController@index');
    Route::get('/goods/category/{category?}', 'GoodsController@index')->name('goods.index');
    Route::get('/goods/{id}', 'GoodsController@show')->name('goods.show');
    Route::get('/auth/register', 'AuthController@create')->name('user.create');
    Route::post('/auth/register', 'AuthController@store')->name('user.store');
    Route::get('/carts', 'CartController@index')->name('carts.index');
    Route::post('/addcart', 'CartController@store')->name('carts.store');
    Route::delete('/cart/{id}', 'CartController@destroy')->name('carts.destroy');
    
    Route::middleware('auth')->group(function() {
    	Route::get('/user', 'UserController@index')->name('user.index');
        Route::get('/my/profile', 'UserProfileController@edit')->name('profile.edit');
        
        Route::get('/my/password', 'PasswordController@edit')->name('password.edit');
        Route::put('/my/password', 'PasswordController@update')->name('password.update');

        Route::resource('/my/address', 'AddressController');
        Route::resource('/my/collections', 'CollectionController');
        Route::resource('/my/order', 'OrderController');

        Route::post('/user/logout', 'LoginController@destroy')->name('user.logout');

        Route::resource('goods.comment', 'GoodsCommentController');
        Route::get('/gocheck', 'ChoosePaymentController@index');

        //Route::get('/pay', 'PayController@index');

        // Route::get('/order/create', 'OrderController@create')->name('order.create');
        // Route::get('/order/store', 'OrderController@store')-》;

    });

    Route::get('/pay/{order}', 'PayController@index')->name('order.pay');
    Route::get('/user/login', 'LoginController@create')->name('user.loginform');
    Route::post('/user/login', 'LoginController@store')->name('user.login');
    Route::resource('/compare', 'ComparesController'); 

    //支付回调
    Route::get('/pay/notify', 'NotifyController@index');

    Route::get('/custom', 'TestController@index');
});
